<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/13
 * Time: 17:06
 */

namespace App\Http\Controllers\Admin;


use App\Http\Logics\Admin\UserLogic;
use App\Http\Traits\UserTrait;
use App\Http\Controllers\BaseController;
class UserController extends BaseController
{
    use UserTrait;
    public function getUserList()
    {
        $limit = $this->limit;
        $nickname = $this->nickname;
        $partner_id = $this->partner_id;
        $data = [
            'nickname' => $nickname,
            'limit' => $limit,
            'partner_id' => $partner_id
        ];
        $response = UserLogic::getUserList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function setUserRole()
    {
        $id = $this->id;
        $role_list = $this->role_list;
        $data = [
            'id' => $id,
            'role_list' => $role_list
        ];
        $response = UserLogic::setUserRole($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * 获取用户的角色列表
     * @return string 返回结果
     */
    public function getUserRoleList()
    {
        $user_id = $this->user_id;
        $data = [
            'user_id' => $user_id
        ];
        $response = UserLogic::getUserRoleList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * 获取每一天用户的数据
     * @return string
     */
    public function getUserByDay()
    {
        $start_date = $this->start_date;
        $end_date = $this->end_date;
        $data = [
            'start_date' => $start_date,
            'end_date' => $end_date
        ];
        $response = UserLogic::getUserByDay($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}